﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YLW.Common.Core.Model;
using YLW.Plat.Jhfw.Model.JhfwCydj;
using YLW.Plat.Jhfw.Model.JhfwHypb;
using YLW.Plat.Jhfw.Model.JhfwHzgl;
using YLW.Plat.Jhfw.Model.JhfwJcsqd;
using YLW.Plat.Jhfw.Model.JhfwJcyy;
using YLW.Plat.Jhfw.Model.JhfwJysqd;
using YLW.Plat.Jhfw.Model.JhfwKsgl;
using YLW.Plat.Jhfw.Model.JhfwMzgh;
using YLW.Plat.Jhfw.Model.JhfwMzyy;
using YLW.Plat.Jhfw.Model.JhfwRygl;
using YLW.Plat.Jhfw.Model.JhfwSspb;
using YLW.Plat.Jhfw.Model.JhfwSssqd;
using YLW.Plat.Jhfw.Model.JhfwSxsqd;
using YLW.Plat.Jhfw.Model.JhfwYzbc;
using YLW.Plat.Jhfw.Model.JhfwZydj;
using YLW.Plat.Jhfw.Model.JhfwZyzk;

namespace YLW.Plat.Jhfw.HL7V3.V3Message
{
    public class V3_ConvertMessage
    {
        public const string receiver_name = "平台交互服务";

        /// <summary>
        /// 交互服务入参出参转换XML消息结构
        /// </summary>
        /// <param name="id_extension">请求流水号</param>
        /// <param name="sender_name">发送者</param>
        /// <param name="req_sername">应用名称</param>
        /// <param name="param_type">参数类型 1：入参；2：过程参数；3：出参；21：error</param>
        /// <param name="api_param">参数内容</param>
        /// <returns></returns>
        public string ConvertMessage(string id_extension, string sender_name, string req_sername, string param_type, string api_param)
        {
            string xmlMessage = string.Empty;

            #region 接口服务名

            List<string> jhfwList = new List<string>();

            //第2部分：个人信息注册、查询服务；
            jhfwList.Add("ylw.pub.his.pat.save"); //推送患者信息
            jhfwList.Add("ylw.jhfw.pat.getlist"); //查询患者信息

            //第3部分：医疗卫生机构注册、查询服务；
            jhfwList.Add("ylw.pub.his.dept.save"); //推送科室信息
            jhfwList.Add("ylw.jhfw.dept.getlist"); //查询科室信息

            //第4部分：医疗卫生人员注册、查询服务；
            jhfwList.Add("ylw.pub.his.emp.save"); //推送人员信息
            jhfwList.Add("ylw.jhfw.emp.getlist"); //查询人员信息

            //第5部分：术语注册、查询服务；
            //第6部分：文档注册、查询服务；

            //第7部分：就诊信息交互服务；
            jhfwList.Add("ylw.pub.his.outpatient.save"); //推送门诊挂号信息
            jhfwList.Add("ylw.jhfw.outpatient.getlist"); //查询门诊挂号信息

            jhfwList.Add("ylw.pub.his.inhospital.save"); //推送住院登记信息
            jhfwList.Add("ylw.jhfw.inhospital.getlist"); //查询住院登记信息

            jhfwList.Add("ylw.pub.his.transfer.save"); //推送住院转科信息
            jhfwList.Add("ylw.jhfw.transfer.getlist"); //查询住院转科信息

            jhfwList.Add("ylw.pub.his.discharge.save"); //推送出院登记信息
            jhfwList.Add("ylw.jhfw.discharge.getlist"); //查询出院登记信息

            //第8部分：医嘱信息交互服务；
            //jhfwList.Add(""); //推送医嘱保存信息
            //jhfwList.Add(""); //查询医嘱保存信息

            //第9部分：申请单信息交互服务；
            jhfwList.Add("ylw.pub.lis.order.save"); //推送检验申请单信息
            jhfwList.Add("ylw.jhfw.lisorder.getlist"); //查询检验申请单信息

            jhfwList.Add("ylw.pub.pacs.order.save"); //推送检查申请单信息
            jhfwList.Add("ylw.jhfw.pacsorder.getlist"); //查询检查申请单信息

            jhfwList.Add("ylw.pub.blood.order.save"); //推送输血申请单信息
            jhfwList.Add("ylw.jhfw.bloodorder.getlist"); //查询输血申请单信息

            jhfwList.Add("ylw.pub.oper.order.save"); //推送手术申请单信息
            jhfwList.Add("ylw.jhfw.operorder.getlist"); //查询手术申请单信息

            //第10部分：预约信息交互服务；
            jhfwList.Add("ylw.pub.his.schulding.save"); //推送号源信息
            jhfwList.Add("ylw.jhfw.hisschulding.getlist"); //查询号源信息

            jhfwList.Add("ylw.pub.his.precontract.save"); //推送门诊预约信息
            jhfwList.Add("ylw.jhfw.hisprecontract.getlist"); //查询门诊预约信息

            jhfwList.Add("ylw.pub.pacs.precontract.save"); //推送检查预约信息
            jhfwList.Add("ylw.jhfw.pacsprecontract.getlist"); //查询检查预约信息

            //第11部分：状态信息交互服务。
            jhfwList.Add("ylw.pub.oper.schulding.save"); //推送手术排班信息
            jhfwList.Add("ylw.jhfw.operschulding.getlist"); //查询手术排班信息

            #endregion

            if (!jhfwList.Contains(req_sername))
            {
                return xmlMessage;
            }

            string api_param_Str = api_param;

            //去除前后" 替换\"为"
            string firstStr = api_param_Str.Substring(0, 1);
            string lastStr = api_param_Str.Substring(api_param_Str.Length - 1, 1);
            if (firstStr == "\"" && lastStr == "\"")
            {
                api_param_Str = api_param_Str.Substring(1, api_param_Str.Length - 1);
            }
            if (api_param_Str.IndexOf("\\\"") > -1)
            {
                api_param_Str = api_param_Str.Replace("\\\"", "\"");
            }

            //请求
            if (param_type == "1")
            {
                switch (req_sername)
                {
                    //第2部分：个人信息注册、查询服务；
                    case "ylw.pub.his.pat.save":
                        xmlMessage = PatientInfoRegisterOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.pat.getlist":
                        xmlMessage = PatientInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第3部分：医疗卫生机构注册、查询服务；
                    case "ylw.pub.his.dept.save":
                        xmlMessage = OrganizationInfoRegisterOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.dept.getlist":
                        xmlMessage = OrganizationInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第4部分：医疗卫生人员注册、查询服务；
                    case "ylw.pub.his.emp.save":
                        xmlMessage = ProviderInfoRegisterOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.emp.getlist":
                        xmlMessage = ProviderInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第5部分：术语注册、查询服务；
                    //第6部分：文档注册、查询服务；
                    //第7部分：就诊信息交互服务；
                    case "ylw.pub.his.outpatient.save":
                        xmlMessage = OutPatientInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.outpatient.getlist":
                        xmlMessage = OutPatientInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.pub.his.inhospital.save":
                        xmlMessage = InPatientInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.inhospital.getlist":
                        xmlMessage = InPatientInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.pub.his.transfer.save":
                        xmlMessage = TransferInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.transfer.getlist":
                        xmlMessage = TransferInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.pub.his.discharge.save":
                        xmlMessage = DischargeInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.discharge.getlist":
                        xmlMessage = DischargeInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第8部分：医嘱信息交互服务；
                    
                    //第9部分：申请单信息交互服务；
                    case "ylw.pub.lis.order.save":
                        xmlMessage = ExamAppInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.lisorder.getlist":
                        xmlMessage = ExamAppInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.pub.pacs.order.save":
                        xmlMessage = CheckAppInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.pacsorder.getlist":
                        xmlMessage = CheckAppInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.pub.blood.order.save":
                        xmlMessage = BloodTransAppInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.bloodorder.getlist":
                        xmlMessage = BloodTransAppInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.pub.oper.order.save":
                        xmlMessage = OperationAppInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.operorder.getlist":
                        xmlMessage = OperationAppInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第10部分：预约信息交互服务；
                    case "ylw.pub.his.schulding.save":
                        xmlMessage = SourceAndScheduleInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.hisschulding.getlist":
                        xmlMessage = SourceAndScheduleInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.pub.his.precontract.save":
                        xmlMessage = OutPatientAppointStatusInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.hisprecontract.getlist":
                        xmlMessage = OutPatientAppointStatusInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.pub.pacs.precontract.save":
                        xmlMessage = CheckAppointStatusInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.pacsprecontract.getlist":
                        xmlMessage = CheckAppointStatusInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第11部分：状态信息交互服务。
                    case "ylw.pub.oper.schulding.save":
                        xmlMessage = OperationScheduleInfoAddOrUpdate(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                    case "ylw.jhfw.operschulding.getlist":
                        xmlMessage = OperationScheduleInfoQuery(api_param_Str, id_extension, sender_name, receiver_name);
                        break;
                }
            }//响应
            else if (param_type == "3")
            {
                ResponseData responseData = JsonConvert.DeserializeObject<ResponseData>(api_param_Str);
                string content_Str = responseData.content.ToString();
                switch (req_sername)
                {
                    //第2部分：个人信息注册、查询服务；
                    case "ylw.jhfw.pat.getlist":
                        xmlMessage = OrganizationInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第3部分：医疗卫生机构注册、查询服务；
                    case "ylw.jhfw.dept.getlist":
                        xmlMessage = OrganizationInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第4部分：医疗卫生人员注册、查询服务；
                    case "ylw.jhfw.emp.getlist":
                        xmlMessage = ProviderInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第5部分：术语注册、查询服务；
                    //第6部分：文档注册、查询服务；
                    //第7部分：就诊信息交互服务；
                    case "ylw.jhfw.outpatient.getlist":
                        xmlMessage = OutPatientInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.jhfw.inhospital.getlist":
                        xmlMessage = InPatientInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.jhfw.transfer.getlist":
                        xmlMessage = TransferInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.jhfw.discharge.getlist":
                        xmlMessage = DischargeInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第8部分：医嘱信息交互服务；

                    //第9部分：申请单信息交互服务；
                    case "ylw.jhfw.lisorder.getlist":
                        xmlMessage = ExamAppInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.jhfw.pacsorder.getlist":
                        xmlMessage = CheckAppInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.jhfw.bloodorder.getlist":
                        xmlMessage = BloodTransAppInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.jhfw.operorder.getlist":
                        xmlMessage = OperationAppInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第10部分：预约信息交互服务；
                    case "ylw.jhfw.hisschulding.getlist":
                        xmlMessage = SourceAndScheduleInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.jhfw.hisprecontract.getlist":
                        xmlMessage = OutPatientAppointStatusInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;

                    case "ylw.jhfw.pacsprecontract.getlist":
                        xmlMessage = CheckAppointStatusInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;
                    //第11部分：状态信息交互服务。
                    case "ylw.jhfw.operschulding.getlist":
                        xmlMessage = OperationScheduleInfoQuery_Response(content_Str, id_extension, sender_name, receiver_name);
                        break;
                    default:
                        xmlMessage = MCCI_ResponseMessage(content_Str, id_extension, sender_name, receiver_name);
                        break;
                }
            }

            return xmlMessage;
        }

        #region 通用新增修改返回
        public string MCCI_ResponseMessage(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            ApiBaseModel jsonData = JsonConvert.DeserializeObject<AddJhfwKsglOut>(api_param_Str);
            string xmlMessage = V3_MCCI_IN000002UV01.MCCI_ResponseMessage(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }
        #endregion

        #region 第2部分：个人信息注册、查询服务；
        public string PatientInfoRegisterOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwHzglIn jsonData = JsonConvert.DeserializeObject<AddJhfwHzglIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRPA_IN201311UV02.PatientInfoRegister(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRPA_IN201314UV02.PatientInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string PatientInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwHzglListIn jsonData = JsonConvert.DeserializeObject<GetJhfwHzglListIn>(api_param_Str);
            string xmlMessage = V3_PRPA_IN201305UV02.PatientInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string PatientInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwHzglListOut jsonData = JsonConvert.DeserializeObject<GetJhfwHzglListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_PRPA_IN201306UV02.PatientInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }
        #endregion

        #region 第3部分：医疗卫生机构注册、查询服务；
        public string OrganizationInfoRegisterOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwKsglIn jsonData = JsonConvert.DeserializeObject<AddJhfwKsglIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRPM_IN401030UV01.OrganizationInfoRegister(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRPM_IN403010UV01.OrganizationInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string OrganizationInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwKsglListIn jsonData = JsonConvert.DeserializeObject<GetJhfwKsglListIn>(api_param_Str);
            string xmlMessage = V3_PRPM_IN406010UV01.OrganizationInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string OrganizationInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwKsglListOut jsonData = JsonConvert.DeserializeObject<GetJhfwKsglListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_PRPM_IN406110UV01.OrganizationInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }
        #endregion

        #region 第4部分：医疗卫生人员注册、查询服务；
        public string ProviderInfoRegisterOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwRyglIn jsonData = JsonConvert.DeserializeObject<AddJhfwRyglIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRPM_IN301010UV01.ProviderInfoRegister(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRPM_IN303010UV01.ProviderInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string ProviderInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwRyglListIn jsonData = JsonConvert.DeserializeObject<GetJhfwRyglListIn>(api_param_Str);
            string xmlMessage = V3_PRPM_IN306010UV01.ProviderInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string ProviderInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwRyglListOut jsonData = JsonConvert.DeserializeObject<GetJhfwRyglListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_PRPM_IN306011UV01.ProviderInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }
        #endregion

        #region 第5部分：术语注册、查询服务；

        #endregion

        #region 第6部分：文档注册、查询服务；

        #endregion

        #region 第7部分：就诊信息交互服务；
        public string OutPatientInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwMzghIn jsonData = JsonConvert.DeserializeObject<AddJhfwMzghIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRPA_IN400001UV_Mzgh.OutPatientInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRPA_IN400002UV_Mzgh.OutPatientInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string OutPatientInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwMzghListIn jsonData = JsonConvert.DeserializeObject<GetJhfwMzghListIn>(api_param_Str);
            string xmlMessage = V3_PRPA_IN900300UV_Mzgh.OutPatientInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string OutPatientInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwMzghListOut jsonData = JsonConvert.DeserializeObject<GetJhfwMzghListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_PRPA_IN900350UV_Mzgh.OutPatientInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }


        public string InPatientInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwZydjIn jsonData = JsonConvert.DeserializeObject<AddJhfwZydjIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRPA_IN400001UV_Zyjz.InPatientInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRPA_IN400002UV_Zyjz.InPatientInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string InPatientInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwZydjListIn jsonData = JsonConvert.DeserializeObject<GetJhfwZydjListIn>(api_param_Str);
            string xmlMessage = V3_PRPA_IN900300UV_Zyjz.InPatientInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string InPatientInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwZydjListOut jsonData = JsonConvert.DeserializeObject<GetJhfwZydjListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_PRPA_IN900350UV_Zyjz.InPatientInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }


        public string TransferInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwZyzkIn jsonData = JsonConvert.DeserializeObject<AddJhfwZyzkIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRPA_IN302011UV_Zyzk.TransferInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRPA_IN302012UV_Zyzk.TransferInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string TransferInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwZyzkListIn jsonData = JsonConvert.DeserializeObject<GetJhfwZyzkListIn>(api_param_Str);
            string xmlMessage = V3_PRPA_IN900300UV_Zyzk.TransferInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string TransferInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwZyzkListOut jsonData = JsonConvert.DeserializeObject<GetJhfwZyzkListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_PRPA_IN900350UV_Zyzk.TransferInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }


        public string DischargeInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwCydjIn jsonData = JsonConvert.DeserializeObject<AddJhfwCydjIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRPA_IN400003UV_Cydj.DischargeInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRPA_IN400002UV_Cydj.DischargeInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string DischargeInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwCydjListIn jsonData = JsonConvert.DeserializeObject<GetJhfwCydjListIn>(api_param_Str);
            string xmlMessage = V3_PRPA_IN900300UV_Cydj.DischargeInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string DischargeInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwCydjListOut jsonData = JsonConvert.DeserializeObject<GetJhfwCydjListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_PRPA_IN900350UV_Cydj.DischargeInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }
        #endregion

        #region 第8部分：医嘱信息交互服务；
        public string OrderInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwYzbcIn jsonData = JsonConvert.DeserializeObject<AddJhfwYzbcIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_POOR_IN200901UV_Yzxx.OrderInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_POOR_IN200902UV_Yzxx.OrderInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string OrderInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwYzbcListIn jsonData = JsonConvert.DeserializeObject<GetJhfwYzbcListIn>(api_param_Str);
            string xmlMessage = V3_QUMT_IN020030UV01_Yzxx.OrderInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string OutPatientInfoQuerOrderInfoQuery_Responsey_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwYzbcListOut jsonData = JsonConvert.DeserializeObject<GetJhfwYzbcListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_QUMT_IN020040UV01_Yzxx.OrderInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }
        #endregion

        #region 第9部分：申请单信息交互服务；
        public string ExamAppInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwJysqdIn jsonData = JsonConvert.DeserializeObject<AddJhfwJysqdIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_POOR_IN200901UV_Jysq.ExamAppInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_POOR_IN200902UV_Jysq.ExamAppInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string ExamAppInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwJysqdListIn jsonData = JsonConvert.DeserializeObject<GetJhfwJysqdListIn>(api_param_Str);
            string xmlMessage = V3_QUMT_IN020030UV01_Jysq.ExamAppInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string ExamAppInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwJysqdListOut jsonData = JsonConvert.DeserializeObject<GetJhfwJysqdListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_QUMT_IN020040UV01_Jysq.ExamAppInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }


        public string CheckAppInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwJcsqdIn jsonData = JsonConvert.DeserializeObject<AddJhfwJcsqdIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_POOR_IN200901UV_Jcsq.CheckAppInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_POOR_IN200902UV_Jcsq.CheckAppInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string CheckAppInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwJcsqdListIn jsonData = JsonConvert.DeserializeObject<GetJhfwJcsqdListIn>(api_param_Str);
            string xmlMessage = V3_QUMT_IN020030UV01_Jcsq.CheckAppInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string CheckAppInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwJcsqdListOut jsonData = JsonConvert.DeserializeObject<GetJhfwJcsqdListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_QUMT_IN020040UV01_Jcsq.CheckAppInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }


        public string BloodTransAppInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwSxsqdIn jsonData = JsonConvert.DeserializeObject<AddJhfwSxsqdIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_POOR_IN200901UV_Sxsq.BloodTransAppInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_POOR_IN200902UV_Sxsq.BloodTransAppInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string BloodTransAppInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwSxsqdListIn jsonData = JsonConvert.DeserializeObject<GetJhfwSxsqdListIn>(api_param_Str);
            string xmlMessage = V3_QUMT_IN020030UV01_Sxsq.BloodTransAppInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string BloodTransAppInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwSxsqdListOut jsonData = JsonConvert.DeserializeObject<GetJhfwSxsqdListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_QUMT_IN020040UV01_Sxsq.BloodTransAppInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }


        public string OperationAppInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwSssqdIn jsonData = JsonConvert.DeserializeObject<AddJhfwSssqdIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_POOR_IN200901UV_Sssq.OperationAppInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_POOR_IN200902UV_Sssq.OperationAppInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string OperationAppInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwSssqdListIn jsonData = JsonConvert.DeserializeObject<GetJhfwSssqdListIn>(api_param_Str);
            string xmlMessage = V3_QUMT_IN020030UV01_Sssq.OperationAppInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string OperationAppInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwSssqdListOut jsonData = JsonConvert.DeserializeObject<GetJhfwSssqdListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_QUMT_IN020040UV01_Sssq.OperationAppInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }
        #endregion

        #region 第10部分：预约信息交互服务；
        public string SourceAndScheduleInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwHypbIn jsonData = JsonConvert.DeserializeObject<AddJhfwHypbIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRSC_IN030101UV.SourceAndScheduleInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRSC_IN030102UV.SourceAndScheduleInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string SourceAndScheduleInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwHypbListIn jsonData = JsonConvert.DeserializeObject<GetJhfwHypbListIn>(api_param_Str);
            string xmlMessage = V3_PRSC_IN100000UV.SourceAndScheduleInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string SourceAndScheduleInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwHypbListOut jsonData = JsonConvert.DeserializeObject<GetJhfwHypbListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_PRSC_IN100500UV.SourceAndScheduleInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }


        public string OutPatientAppointStatusInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwMzyyIn jsonData = JsonConvert.DeserializeObject<AddJhfwMzyyIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRPA_IN410001UV_Mzyy.OutPatientAppointStatusInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRPA_IN410002UV_Mzyy.OutPatientAppointStatusInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string OutPatientAppointStatusInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwMzyyListIn jsonData = JsonConvert.DeserializeObject<GetJhfwMzyyListIn>(api_param_Str);
            string xmlMessage = V3_PRPA_IN900300UV_Mzyy.OutPatientAppointStatusInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string OutPatientAppointStatusInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwMzyyListOut jsonData = JsonConvert.DeserializeObject<GetJhfwMzyyListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_PRPA_IN900350UV_Mzyy.OutPatientAppointStatusInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }


        public string CheckAppointStatusInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwJcyyIn jsonData = JsonConvert.DeserializeObject<AddJhfwJcyyIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRSC_IN010101UV01_Jcyy.CheckAppointStatusInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRSC_IN010201UV01_Jcyy.CheckAppointStatusInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string CheckAppointStatusInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwJcyyListIn jsonData = JsonConvert.DeserializeObject<GetJhfwJcyyListIn>(api_param_Str);
            string xmlMessage = V3_QUMT_IN020030UV01_Jcyy.CheckAppointStatusInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string CheckAppointStatusInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwJcyyListOut jsonData = JsonConvert.DeserializeObject<GetJhfwJcyyListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_QUMT_IN020040UV01_Jcyy.CheckAppointStatusInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }
        #endregion

        #region 第11部分：状态信息交互服务。
        public string OperationScheduleInfoAddOrUpdate(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            string xmlMessage = string.Empty;

            AddJhfwSspbIn jsonData = JsonConvert.DeserializeObject<AddJhfwSspbIn>(api_param_Str);

            if (jsonData.dotype.ToUpper() == "ADD")
            {
                xmlMessage = V3_PRSC_IN010101UV01_Sspb.OperationScheduleInfoAdd(jsonData, id_extension, sender_name, receiver_name);
            }
            else
            {
                xmlMessage = V3_PRSC_IN010201UV01_Sspb.OperationScheduleInfoUpdate(jsonData, id_extension, sender_name, receiver_name);
            }

            return xmlMessage;
        }

        public string OperationScheduleInfoQuery(string api_param_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwSspbListIn jsonData = JsonConvert.DeserializeObject<GetJhfwSspbListIn>(api_param_Str);
            string xmlMessage = V3_QUMT_IN020030UV01_Sspb.OperationScheduleInfoQuery(jsonData, id_extension, sender_name, receiver_name);
            return xmlMessage;
        }

        public string OperationScheduleInfoQuery_Response(string content_Str, string id_extension, string sender_name, string receiver_name)
        {
            GetJhfwSspbListOut jsonData = JsonConvert.DeserializeObject<GetJhfwSspbListOut>(content_Str);
            string xmlMessage = xmlMessage = V3_QUMT_IN020040UV01_Sspb.OperationScheduleInfoQuery_Response(jsonData, id_extension, receiver_name, sender_name);
            return xmlMessage;
        }
        #endregion

    }
}
